package de.tabuma.customer.view;

import de.tabuma.customer.*;
import de.tabuma.lib.tabumaview;
import java.io.PrintWriter;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author alefen
 */
public class createView extends tabumaview {

    public createView(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {

        String addContent = "Add customer to list.";
        String customerName = "costumer name";
        String add = "Add";
        String back = "Back";
        out.println("<form action=\""+this.getServlet()+"\">");
        out.println("<div class=\"contentContent\">");
        out.println(addContent);
        out.println("</div>");
        out.println("<div class=\"contentContent\">");
        out.println("<div class=\"col1\">");
        out.println("<div class=\"col1_head\">"+customerName+"</div>");
        out.println("<div class=\"col1_content\"><input type=\"text\" name=\""+constants.customerFieldName+"\" value=\"\"/></div>");
        out.println("</div>");
        out.println("<div class=\"col2\"></div>");
        out.println("</div>");
        out.println("<div class=\"contentContent\">");
        Enumeration enu = this.getParameter().keys();
        while(enu.hasMoreElements()) {
            String key = (String) enu.nextElement();
            String value = (String) this.getParameter().get(key);
            out.println("<input type=\"hidden\" name=\""+key+"\" value=\""+value+"\"/>");
        }
        out.println("<input type=\"hidden\" name=\""+constants.paramName+"\" value=\""+constants.ACTION_CREATE+"\"/>");
        out.println("<input type=\"hidden\" name=\""+constants.paramAdd+"\" value=\"true\"/>");
        out.println("<input type=\"submit\" class=\"button\" value=\""+add+"\"/>");        out.println("<input type=\"button\" class=\"button\" value=\""+back+"\" onClick=\"javascript:history.back()\"/>");
        out.println("</div>");
        out.println("</form>");

    }
    
}
